package com.lagou.stage6module1.producer;

import com.lagou.stage6module1.service.OrderService;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderController {
    @Autowired
    private AmqpTemplate rabbitTemplate;
    @Autowired
    private OrderService orderService;

    @RequestMapping("/order/{orderId}")
    public String sendMessage(@PathVariable String orderId){
        orderService.save(orderId);
        return "ok";
    }

    @RequestMapping("/order/pay/{orderId}")
    public String pay(@PathVariable String orderId){
        orderService.pay(orderId);
        System.out.println("支付成功："+orderId);
        return "pay-ok";
    }
}
